/**
 * @author[wengcj]
 * @version[创建日期，2021/11/4 11:38]
 * @function[功能简介 ]
 **/
package com.example.iocdemo;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class OnClickInvocationHandler implements InvocationHandler {

    private final Object content;//可以是Activity，fragment，dialog
    private final Method method;

    public OnClickInvocationHandler(Object content, Method method) {
        this.content = content;
        this.method = method;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (content != null) {
            //这里的回调是 setOnClickListener的回调
            //method 也就是start方法
            return  this.method.invoke(content,args);
        }
        return null;
    }
}
